import Vue from 'vue'
import Router from 'vue-router'
import Gheader from '@/views/GlobleHeader/globleHeader'
import Gfooter from '@/views/GlobleFooter/globleFooter'
import { Loadmore, Spinner, Field } from 'mint-ui'
import itimsRouter from './modules/itims'

Vue.component(Field.name, Field)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading
Vue.component(Loadmore.name, Loadmore)
Vue.component(Spinner.name, Spinner)
Vue.component('gheader', Gheader)
Vue.component('gfooter', Gfooter)
Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  // { path: '/404', component: () => import('@/views/404'), hidden: true },
  {
    path: '/ucAuditLog',
    name: '用户审计',
    component: () => import('@/views/table/log/auditLog'),
    meta: { title: '用户审计', icon: 'table' },
    hidden: true
  },
  // {
  //   path: '/ucAddLog',
  //   name: '添加日志',
  //   component: () => import('@/views/table/log/addLog'),
  //   meta: { title: '添加日志', icon: 'table' },
  //   hidden: true
  // },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    },
    {
      path: 'amap',
      component: () => import('@/views/itims/amap/amap')
    },{
      path: 'changePassword',
      name: '修改密码',
      component: () => import('@/views/table/user/changePassword'),
      meta: { title: '修改密码', icon: 'table' },
    }]
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  }
  
  // { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/ispmanager',
    component: Layout,
    redirect: '/orders',
    meta: { roles: ['admin','zxtest'] },
    authority: 'ispmanager',
    children: [
      {
        path: 'orders',
        name: '订单列表',
        component: () => import('@/views/orders/index'),
        meta: { title: '订单列表', icon: 'table', roles: ['admin','zxtest'], noCache: true },
        authority: 'orders'
      },
      {
        path: 'bills',
        name: '账单列表',
        component: () => import('@/views/bills/index'),
        meta: { title: '账单列表', icon: 'table', roles: ['admin','zxtest'],keepAlive:true },
        authority: 'bills'
      },
      {
        path: 'users',
        name: '用户列表',
        component: () => import('@/views/users/index'),
        meta: { title: '用户列表', icon: 'table', roles: ['admin','zxtest'] },
        authority: 'users'
      },
      {
        path: 'orderDetailReport',
        name: '订单明细报表',
        component: () => import('@/views/orderDetailReport/index'),
        meta: { title: '订单明细报表', icon: 'table', roles: ['admin','zxtest'] },
        authority: 'orderDetailReport'
      },
      {
        path: 'financialReconciliationReport',
        name: '财务对账报表',
        component: () => import('@/views/financialReconciliationReport/index'),
        meta: { title: '财务对账报表', icon: 'table', roles: ['admin','zxtest'] },
        authority: 'financialReconciliationReport'
      },
      {
        path: 'unpaidBillReport',
        name: '未还款账单报表',
        component: () => import('@/views/unpaidBillReport/index'),
        meta: { title: '未还款账单报表', icon: 'table', roles: ['admin','zxtest'] },
        authority: 'unpaidBillReport'
      },
      {
        path: 'xlbOrders',
        name: '信联宝订单管理',
        component: () => import('@/views/xlbOrders/index'),
        meta: { title: '信联宝订单管理', icon: 'table', roles: ['admin','zxtest'] },
        authority: 'xlbOrders'
      },
      {
        path: 'cdkey',
        name: '兑换码管理',
        component: () => import('@/views/cdkey/index'),
        meta: { title: '兑换码管理', icon: 'table', roles: ['admin'] },
        authority: 'cdkey'
      }
    ]
  },
  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: 'Example', icon: 'example', roles: ['admin'] },
    authority: 'example',
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: 'Table', icon: 'table', roles: ['admin'] },
        authority: 'table'
      },
      {
        path: 'test',
        name: '上传测试',
        component: () => import('@/views/test/index'),
        meta: { title: '上传测试', icon: 'table', roles: ['admin']},
        authority: 'test'
      },
      {
        path: 'orders',
        name: '订单列表',
        component: () => import('@/views/orders/index'),
        meta: { title: '订单列表', icon: 'table', roles: ['admin'], noCache: true },
        authority: 'orders'
      },
      {
        path: 'bills',
        name: '账单列表',
        component: () => import('@/views/bills/index'),
        meta: { title: '账单列表', icon: 'table', roles: ['admin'],keepAlive:true },
        authority: 'bills'
      },
      {
        path: 'users',
        name: '用户列表',
        component: () => import('@/views/users/index'),
        meta: { title: '用户列表', icon: 'table', roles: ['admin'] },
        authority: 'users'
      },
      {
        path: 'orderDetailReport',
        name: '订单明细报表',
        component: () => import('@/views/orderDetailReport/index'),
        meta: { title: '订单明细报表', icon: 'table', roles: ['admin'] },
        authority: 'orderDetailReport'
      },
      // {
      //   path: 'salesReport',
      //   name: '销售报表',
      //   component: () => import('@/views/salesReport/index'),
      //   meta: { title: '销售报表', icon: 'table', roles: ['admin'] }
      // },
      // {
      //   path: 'cardASplitReport',
      //   name: 'A卡拆分报表',
      //   component: () => import('@/views/cardASplitReport/index'),
      //   meta: { title: 'A卡拆分报表', icon: 'table', roles: ['admin'] }
      // },
      {
        path: 'financialReconciliationReport',
        name: '财务对账报表',
        component: () => import('@/views/financialReconciliationReport/index'),
        meta: { title: '财务对账报表', icon: 'table', roles: ['admin'] },
        authority: 'financialReconciliationReport'
      },
      {
        path: 'unpaidBillReport',
        name: '未还款账单报表',
        component: () => import('@/views/unpaidBillReport/index'),
        meta: { title: '未还款账单报表', icon: 'table', roles: ['admin'] },
        authority: 'unpaidBillReport'
      },
      {
        path: 'xlbOrders',
        name: '信联宝订单管理',
        component: () => import('@/views/xlbOrders/index'),
        meta: { title: '信联宝订单管理', icon: 'table', roles: ['admin'] },
        authority: 'xlbOrders'
      },
      {
        path: 'cdkey',
        name: '兑换码管理',
        component: () => import('@/views/cdkey/index'),
        meta: { title: '兑换码管理', icon: 'table', roles: ['admin'] },
        authority: 'cdkey'
      },
      {
        path: 'complexTable',
        name: '应用管理',
        component: () => import('@/views/table/app/complexTable'),
        meta: { title: '应用管理', icon: 'table', roles: ['admin'] },
        authority: 'complexTable'
      },
      {
        path: 'ucService',
        name: '服务管理',
        component: () => import('@/views/table/service/ucService'),
        meta: { title: '服务管理', icon: 'table', roles: ['admin'] },
        authority: 'ucService'
      },
      {
        path: 'ucUser',
        name: '用户管理',
        component: () => import('@/views/table/user/ucUser'),
        meta: { title: '用户管理', icon: 'table', roles: ['admin'] },
        authority: 'ucUser'
      },
      {
        path: 'ucRole',
        name: '角色管理',
        component: () => import('@/views/table/role/ucRole'),
        meta: { title: '角色管理', icon: 'table', roles: ['admin'] },
        authority: 'ucRole'
      },
      {
        path: 'ucMenu',
        name: '菜单管理',
        component: () => import('@/views/table/menu/ucMenu'),
        meta: { title: '菜单管理', icon: 'table', roles: ['admin'] },
        authority: 'ucMenu'
      },
      {
        path: 'ucOrgan',
        name: '机构管理',
        component: () => import('@/views/table/organ/ucorgan'),
        meta: { title: '机构管理', icon: 'table', roles: ['admin'] },
        authority: 'ucOrgan'
      },
      {
        path: 'ucLogHistory',
        name: '登入历史',
        component: () => import('@/views/table/loginlog/ucloginhistory'),
        meta: { title: '登入历史', icon: 'table' , roles: ['admin']},
        authority: 'ucLogHistory'
      },
      {
        path: 'changePassword',
        name: '修改密码',
        component: () => import('@/views/table/user/changePassword'),
        meta: { title: '修改密码', icon: 'table', roles: ['admin'] },
        authority: 'changePassword'
      }
    ]
  },
  itimsRouter,
  {
    path: '/form',
    component: Layout,
    meta: { roles: ['admin'] },
    authority: 'form',
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: 'Form', icon: 'form', roles: ['admin'] },
        authority: 'index'
      }
    ]
  },
  {
    path: '/testform',
    component: Layout,
    redirect: '/testform/form',
    name: 'TestForm',
    meta: { title: 'TestFrom', icon: 'tab', roles: ['admin'] },
    authority: 'testform',
    children: [
      {
        path: 'form',
        name: 'TestForm',
        component: () => import('@/views/testform/index'),
        meta: { title: 'Form', icon: 'eye' , roles: ['admin']},
        authority: 'form'
      }
    ]
  },
  {
    path: '/bootdemo',
    component: Layout,
    redirect: '/bootdemo/enchche',
    name: 'bootdemo',
    meta: { title: 'bootdemo', icon: 'example', roles: ['admin'] },
    authority: 'bootdemo',
    children: [
      {
        path: 'enchche',
        name: 'Table',
        component: () => import('@/views/ehcache/ehcache'),
        meta: { title: 'enchche', icon: 'table', roles: ['admin'] },
        authority: 'enchche'
      },
      {
        path: 'rediscache',
        name: 'rediscache',
        component: () => import('@/views/redis/redis'),
        meta: { title: 'rediscache', icon: 'table', roles: ['admin'] },
        authority: 'rediscache'
      },
      {
        path: 'amqp',
        name: 'amqp',
        component: () => import('@/views/amqp/amqp'),
        meta: { title: 'amqp', icon: 'table' , roles: ['admin']},
        authority: 'amqp'
      },
      {
        path: 'mail',
        name: 'mail',
        component: () => import('@/views/mail/mail'),
        meta: { title: 'mail', icon: 'table' , roles: ['admin']},
        authority: 'mail'
      },
      {
        path: 'quartz',
        name: 'quartz',
        component: () => import('@/views/quartz/quartz'),
        meta: { title: 'quartz', icon: 'table' , roles: ['admin'] },
        authority: 'quartz'
      },
      {
        path: 'corn',
        name: 'corn',
        component: () => import('@/views/corn/cornindex'),
        meta: { title: 'quartzcorn', icon: 'table' , roles: ['admin'] },
        authority: 'corn'
      }
    ]
  },
  {
    path: '/flow',
    component: Layout,
    redirect: '/flow/deployment',
    name: 'flow',
    meta: { title: 'flow', icon: 'example' , roles: ['admin'] },
    authority: 'flow',
    children: [
      {
        path: 'deployment',
        name: 'deployment',
        component: () => import('@/views/flow/deployment/deployment'),
        meta: { title: 'deployment', icon: 'table' },
        authority: 'deployment'
      },
      {
        path: 'definition',
        name: 'definition',
        component: () => import('@/views/flow/definition/definitions'),
        meta: { title: 'definition', icon: 'table' },
        authority: 'definition'
      },
      {
        path: 'instance',
        name: 'instance',
        component: () => import('@/views/flow/instance/instance'),
        meta: { title: 'instance', icon: 'table' },
        authority: 'instance'
      },
      {
        path: 'task',
        name: 'task',
        component: () => import('@/views/flow/task/task'),
        meta: { title: 'task', icon: 'table' },
        authority: 'task'
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
